home *** CD-ROM | disk | FTP | other *** search
/ Run Magazine ReRun: Productivity Pak 3 / rerun-productivity-pak-iii-side-a.d64 / runcalc 64.bas (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  12KB  |  452 lines

  1. 1 dimda$(30,30),fc$(30,30),cu$(2),da(30,30)
  2. 5 cu$(1)=" [146][157]":cu$(2)=" [157]"
  3. 6 pa=1:z=0:p=100
  4. 20 gosub10000
  5. 30 print"";
  6. 40 fort=1to10:getg$:next
  7. 50 in$=""
  8. 52 de=0
  9. 54 printcu$(pa);
  10. 56 de=de+1
  11. 60 getg$
  12. 61 ifg$=chr$(34)then60
  13. 62 ifg$<>""then70
  14. 65 ifde<7then54
  15. 68 pa=3-pa
  16. 70 ifg$=""thenifc<27thenc=c+1:gosub10000:goto30
  17. 71 ifg$="[145]"thenifrd>0thenrd=rd-1:gosub10000:goto30
  18. 72 ifg$=""thenc=0:rd=0:goto9900
  19. 73 ifg$="_"then22000
  20. 74 ifg$="[147]"then350
  21. 75 ifg$=""thenifrd<6thenrd=rd+1:gosub10000:goto30
  22. 76 ifg$=""org$="[145]"org$=""then60
  23. 77 ifg$="[136]"and(peek(53281)and15)<15thenpoke53281,(peek(53281)+1):goto60
  24. 78 ifg$="[136]"and(peek(53281)and15)=15thenpoke53281,0:goto60
  25. 79 ifg$="[137]"then400
  26. 80 ifg$="[157]"thenifc>0thenc=c-1:gosub10000:goto30
  27. 81 ifg$="[133]"thenprint"f[146]";:goto140
  28. 82 ifg$="[139]"then13000
  29. 83 ifg$="[140]"and(peek(53280)and15)=15thenpoke53280,0:goto60
  30. 84 ifg$="[140]"and(peek(53280)and15)<15thenpoke53280,peek(53280)+1:goto60
  31. 85 ifg$="[134]"then24000
  32. 86 ifg$="[138]"then25000
  33. 87 ifg$="[135]"then13400
  34. 90 ifg$=chr$(13)then300
  35. 100 ifg$=chr$(20)then200
  36. 125 iflen(in$)>30then52
  37. 130 printg$;
  38. 140 in$=in$+g$
  39. 199 goto52
  40. 200 iflen(in$)=0then60
  41. 210 iflen(in$)=1thenprintchr$(20);:goto50
  42. 220 in$=left$(in$,len(in$)-1):printchr$(20);
  43. 230 goto60
  44. 300 ifleft$(in$,1)<"a"orleft$(in$,1)>"z"then19010
  45. 305 ifmid$(in$,2,1)<"0"ormid$(in$,2,1)>"9"then19020
  46. 306 ifmid$(in$,3,1)<"0"ormid$(in$,3,1)>":"then19030
  47. 310 ifval(mid$(in$,2,2))<0orval(mid$(in$,2,2))>29then19000
  48. 320 ifmid$(in$,3,1)<>":"andmid$(in$,4,1)<>":"then19040
  49. 330 goto500
  50. 350 gosub12500:ifg$="n"then9900
  51. 355 run
  52. 400 printchr$(19);:print
  53. 410 printchr$(18);" maximum precision (0 to 6) press key "
  54. 420 getg$:ifg$<"0"org$>"6"then420
  55. 430 p=10^val(g$)
  56. 440 goto9900
  57. 500 gosub12000
  58. 520 ifmid$(in$,3,1)=":"thens=4:goto540
  59. 530 ifmid$(in$,4,1)=":"thens=5
  60. 540 ifmid$(in$,s,1)=chr$(133)then2000
  61. 550 ifmid$(in$,s,1)=""thenda$(r,cd)="":da(r,cd)=0:goto9900
  62. 1450 iffc$(r,cd)<>""thengoto11000
  63. 1500 t$=mid$(in$,s,1)
  64. 1510 ift$<"0"ort$>"9"thenift$<>"+"andt$<>"-"then1560
  65. 1512 da(r,cd)=val(mid$(in$,s,19))
  66. 1513 da$(r,cd)=mid$(in$,s,19)
  67. 1515 iflen(da$(r,cd))=9then1590
  68. 1518 iflen(da$(r,cd))>9then1580
  69. 1520 forx=1to9-len(da$(r,cd))
  70. 1530 da$(r,cd)=" "+da$(r,cd)
  71. 1540 next
  72. 1545 goto9900
  73. 1560 da$(r,cd)=mid$(in$,s,9):goto9900
  74. 1580 da$(r,cd)="*********"
  75. 1590 goto9900
  76. 2000 ifmid$(in$,s+1,1)="t"andlen(in$)=s+1then2010
  77. 2005 goto2020
  78. 2010 ifleft$(in$,2)<>"a0"then19050
  79. 2015 z=1:ct=cd:rt=0:goto9900
  80. 2020 ifmid$(in$,s+1,1)="o"andlen(in$)=s+1then2030
  81. 2025 goto2040
  82. 2030 z=0:goto9900
  83. 2040 ifmid$(in$,s+1,3)="sum"thengosub14000:goto9900
  84. 2050 ifmid$(in$,s+1,3)="min"thengosub14000:goto9900
  85. 2060 ifmid$(in$,s+1,3)="max"thengosub14000:goto9900
  86. 2070 ifmid$(in$,s+1,3)="avg"thengosub14000:goto9900
  87. 2080 ifmid$(in$,s+1,3)="cop"thengosub14000:gosub26010:goto2085
  88. 2081 goto2110
  89. 2085 ifr1=r2then2100
  90. 2088 forx=r1tor2
  91. 2090 da(x,c1)=da(r,cd):da$(x,c1)=da$(r,cd)
  92. 2095 next:goto9900
  93. 2100 forx=c1toc2
  94. 2103 da(r1,x)=da(r,cd):da$(r1,x)=da$(r,cd)
  95. 2106 next:goto9900
  96. 2110 ifmid$(in$,s+1,1)="c"andlen(in$)=s+1then2120
  97. 2115 goto2130
  98. 2120 gosub12500
  99. 2125 ifg$="n"thengoto9900
  100. 2128 da(r,cd)=0:da$(r,cd)="":fc$(r,cd)="":goto9900
  101. 2130 ifmid$(in$,s+1,1)="v"andlen(in$)=s+1then2140
  102. 2135 goto2150
  103. 2140 gosub12600:goto9900
  104. 2145 goto9900
  105. 2150 ifmid$(in$,s+1,1)="j"andlen(in$)=s+1then2160
  106. 2155 goto2500
  107. 2160 c=val(mid$(in$,2,2)):ifc>27thenc=27
  108. 2162 ifasc(left$(in$,1))>84thenrd=6
  109. 2163 ifasc(left$(in$,1))<=84thenrd=0
  110. 2165 goto9900
  111. 2500 ifmid$(in$,s+1,1)<"a"ormid$(in$,s+1,1)>"z"then19060
  112. 2505 ifmid$(in$,s+2,1)<"0"ormid$(in$,s+2,1)>"9"then19070
  113. 2510 ifval(mid$(in$,s+2,2))<0orval(mid$(in$,s+2,2))>29then19080
  114. 2580 t$=mid$(in$,s+3,1)
  115. 2590 ift$="+"ort$="-"ort$="*"ort$="/"ort$="^"then2650
  116. 2600 t$=mid$(in$,s+4,1)
  117. 2610 ift$="+"ort$="-"ort$="*"ort$="/"ort$="^"then2670
  118. 2620 goto19090
  119. 2650 s1=s+4:goto2680
  120. 2670 s1=s+5
  121. 2680 ifmid$(in$,s1,1)<"a"ormid$(in$,s1,1)>"z"then3000
  122. 2690 ifmid$(in$,s1+1,1)<"0"ormid$(in$,s1+1,1)>"9"then19100
  123. 2700 ifval(mid$(in$,s1+1,2))<0orval(mid$(in$,s1+1,2))>29then19110
  124. 2710 goto3100
  125. 3000 ift$="/"andval(mid$(in$,s1,19))=0then19120
  126. 3100 fc$(r,cd)=mid$(in$,s,19)
  127. 9900 gosub10000
  128. 9910 printchr$(19);
  129. 9999 goto50
  130. 10000 print"[147]                                        "
  131. 10015 ifz=1thenprinttab(5);ct;tab(16);c+1;tab(27);c+2:goto10021
  132. 10020 printtab(5);c;tab(16);c+1;tab(27);c+2
  133. 10021 ifz=1then10026
  134. 10022 printchr$(65+rd);:printtab(2);da$(rd,c);
  135. 10023 printtab(13);da$(rd,c+1);
  136. 10024 printtab(24);da$(rd,c+2)
  137. 10025 goto10030
  138. 10026 printchr$(65+rt);:printtab(2);da$(rt,ct);
  139. 10027 printtab(13);da$(rt,c+1);
  140. 10028 printtab(24);da$(rt,c+2)
  141. 10030 forr=rd+1tord+19
  142. 10040 printchr$(65+r);
  143. 10045 ifz=1thenprinttab(2);da$(r,ct);:goto10060
  144. 10050 printtab(2);da$(r,c);
  145. 10060 printtab(13);da$(r,c+1);
  146. 10070 printtab(24);da$(r,c+2)
  147. 10080 next
  148. 10090 return
  149. 11000 printchr$(19);:print
  150. 11005 printchr$(18);"protected formula  ";fc$(r,cd)
  151. 11010 getg$:ifg$=""then11010
  152. 11020 goto20
  153. 12000 r=asc(left$(in$,1))-65
  154. 12010 cd=val(mid$(in$,2,2))
  155. 12020 return
  156. 12500 printchr$(19);:print
  157. 12505 printchr$(18);" are you sure press 'y' or 'n' "
  158. 12510 getg$:ifg$<>"y"andg$<>"n"then12510
  159. 12520 return
  160. 12550 printchr$(19);:print
  161. 12555 printchr$(18);" working    please wait...             "
  162. 12560 return
  163. 12600 printchr$(19);:print
  164. 12605 printchr$(18);
  165. 12606 iffc$(r,cd)<>""thenprint"form. ";fc$(r,cd);" - ";
  166. 12607 print"val.";da(r,cd)
  167. 12610 getg$:ifg$=""then12610
  168. 12620 return
  169. 13000 printchr$(19);:print
  170. 13005 printchr$(18);"press 'space' to print-'return' to exit"
  171. 13010 getg$:ifg$<>" "andg$<>chr$(13)then13010
  172. 13020 ifg$=chr$(13)then9900
  173. 13025 gosub12550
  174. 13030 open4,4
  175. 13040 r=0:cd=0
  176. 13050 iffc$(r,cd)<>""then13080
  177. 13060 cd=cd+1:ifcd=30thencd=0:r=r+1:ifr=26then13300
  178. 13065 iffc$(r,cd)<>""then13080
  179. 13070 goto13060
  180. 13080 print#4,chr$(r+65);cd;
  181. 13090 print#4,"  ";fc$(r,cd)
  182. 13100 goto13060
  183. 13300 print#4,chr$(10)
  184. 13310 print#4
  185. 13320 close4:goto9900
  186. 13400 printchr$(147):print"          print spreadsheet"
  187. 13410 print:print
  188. 13420 print"     enter the top left cell
  189. 13430 [153]"         to be printed or
  190. 13440 print"      press 'return' to exit"
  191. 13450 print:g$=""
  192. 13460 input"              ";g$:ifg$=""then9900
  193. 13465 ifg$<"a0"org$>"z9"then13400
  194. 13467 r1=asc(left$(g$,1))-65:tc=val(mid$(g$,2)):iftc>29then13400
  195. 13470 printchr$(147):print"          print spreadsheet"
  196. 13472 print:print
  197. 13474 print"    enter the bottom right cell
  198. 13476 [153]"         to be printed or
  199. 13478 print"      press 'return' to exit"
  200. 13480 print:t$=""
  201. 13482 input"              ";t$:ift$=""then9900
  202. 13484 ift$<"a0"org$>"z9"then13470
  203. 13485 gosub13700
  204. 13486 r2=asc(left$(t$,1))-65:t=val(mid$(t$,2)):ift>29ort<tcthen13470
  205. 13487 ifr2<r1then13470
  206. 13488 gosub13700
  207. 13490 t$=chr$(16)
  208. 13500 open4,4
  209. 13505 print#4,chr$(10)
  210. 13525 forr=r1tor2
  211. 13535 iftc>tthengosub13700
  212. 13540 print#4,"  ";da$(r,tc);
  213. 13545 iftc+1>tthen13600
  214. 13550 forx=1to11-len(da$(r,tc)):print#4," ";:next:print#4,da$(r,tc+1);
  215. 13555 iftc+2>tthen13600
  216. 13560 forx=1to11-len(da$(r,tc+1)):print#4," ";:next:print#4,da$(r,tc+2);
  217. 13565 iftc+3>tthen13600
  218. 13570 forx=1to11-len(da$(r,tc+2)):print#4," ";:next:print#4,da$(r,tc+3);
  219. 13575 iftc+4>tthen13600
  220. 13577 forx=1to11-len(da$(r,tc+3)):print#4," ";:next:print#4,da$(r,tc+4);
  221. 13580 iftc+5>tthen13600
  222. 13585 forx=1to11-len(da$(r,tc+4)):print#4," ";:next:print#4,da$(r,tc+5);
  223. 13590 iftc+6>tthen13600
  224. 13595 forx=1to11-len(da$(r,tc+5)):print#4," ";:next:print#4,da$(r,tc+6);
  225. 13600 print#4,chr$(13);:next
  226. 13610 tc=tc+7:iftc>tthenprint#4:close4:goto9900
  227. 13620 printchr$(147):print:print
  228. 13630 print"      ...... more to come ......"
  229. 13635 print
  230. 13640 print"      please align printer paper"
  231. 13650 print"     and press 'space' to continue"
  232. 13655 getg$:ifg$<>" "then13655
  233. 13656 gosub13700
  234. 13660 goto13505
  235. 13700 printchr$(147):print:print
  236. 13710 print"      ......    working   ......"
  237. 13720 return
  238. 14000 s=s+3
  239. 14010 ifmid$(in$,s+1,1)<"a"ormid$(in$,s+1,1)>"z"then19060
  240. 14020 ifmid$(in$,s+2,1)<"0"ormid$(in$,s+2,1)>"9"then19070
  241. 14030 ifmid$(in$,s+3,1)<"-"ormid$(in$,s+3,1)>"9"then19070
  242. 14040 ifval(mid$(in$,s+2,2))<0orval(mid$(in$,s+2,2))>29then19080
  243. 14050 ifmid$(in$,s+3,1)<>"-"andmid$(in$,s+4,1)<>"-"then19130
  244. 14060 ifmid$(in$,s+4,1)="-"thens1=5+s:goto14070
  245. 14065 s1=4+s
  246. 14070 ifmid$(in$,s1,1)<"a"ormid$(in$,s1,1)>"z"then19140